'use strict';

/**
 * @ngdoc directive
 * @name jgappApp.directive:chatusers
 * @description
 * # chatusers
 */
angular.module('jgappApp')
    .directive('chatusers',function($window, $rootScope, $location) {
        return {
            scope: {
                confirm: "=confirm"
            },
            replace: true,
            template: '<div class="chat-users fs12 flex">' +
                '<div class="w85 scrollx">' +
                '<div class="chat-userlist" style="min-width:{{listwidth}}px">' +
                '<div class="item-avtar lh30 tc" ng-repeat="item in userArr track by item.id||item.userId"><img ng-src={{item.iconCls}} alt="" ng-if="item.iconCls">{{item.name||item.personName|username}}</div>' +
                '</div>' +
                '</div>' +
                '<div class="w15 btn fs14" ng-click="submit()">确定</div>' +
                '</div>',
            restrict: 'AE',
            link: function postLink(scope, element, attrs) {
                // element.text('this is the logList directive');
                $rootScope.$on("userArrchange", function() {
                    scope.userArr = $rootScope.userArr
                    scope.listwidth = $rootScope.userArr.length * 40
                })
                scope.listwidth = $rootScope.userArr && $rootScope.userArr.length * 40 || 0
                scope.submit = function() {
                    scope.confirm();
                }
            }
        };
    });
